package org.feiye.studyday26;

public class RunnableTest implements Runnable {
	@Override
	public void run() {
		for (int i = 1; i <= 20; i++) {
			System.out.println(i + "\t你好\t" + Thread.currentThread().getName());
		}

	}

	public static void main(String[] args) {
		// 创建两个子线程，每个线程均输出20次消息数字、“你好”、线程名
		// 观察多个线程交替执行的过程
		RunnableTest r = new RunnableTest();
		Thread t = new Thread(r, "子线程1");
		Thread t1 = new Thread(r, "子线程2");
		t.start();
		t1.start();
		System.out.println("获得当前线程的数量：" + Thread.activeCount());// 获得当前线程的数量
	}

}
